# Copyright 2024-2025 Wenze Wei
#
# This file is part of StadionOS.
#
# This Source Code Form is subject to the terms of the GNU General Public License, v. 2.0.
# You can obtain a copy of the GPL at
# https://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
# the specific language governing rights and limitations under the License.

ARCH := $(shell uname -m)
CC = gcc
CFLAGS = -g -fPIC -Wfatal-errors -Wno-error=unused-function -lyaml
SRC_DIRS = malloc stdio string time math error fs process lpi 

SRCS = $(shell find $(SRC_DIRS) -name "*.c")
OBJS = $(SRCS:.c=.o)

TARGET = libsys.a

all: $(TARGET)

$(TARGET): $(OBJS)
	@ar rcs $@ $^
	@echo "\nDone."

%.o: %.c
	@$(CC) $(CFLAGS) -c $< -o $@
	@echo "CC $<"

clean:
	@for obj in $(OBJS) $(TARGET); do \
		rm -f $$obj && echo "CLEAN $$obj"; \
	done
	@echo "\nDone."

.PHONY: all clean
